-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Editorial review: Document canvas context lang attribute #39642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Preview URLs
External URLs (2)URL:
(comment last updated: 2025-05-30 07:12:17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for adding this.
The behavior of lang = inherit
for the offscreen case is not super intuitive due to technical limitations with offscreen canvas. Any alternative would be even less intuitive because the behavior would depend on how the offscreen was created and whether it was used in a worker.
|
||
### Language support for offscreen canvases | ||
|
||
This example is the same as the previous example, except that the font is rendered to a {{domxref("OffscreenCanvasRenderingContext2D")}} then the resulting bitmap is transferred to the on-screen `<canvas>` to display. The `lang` attribute can be used to provide localization support to the off-screen canvas in just the same way as the regular on-screen `<canvas>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inherit
value behaves differently for Offscreen in that it is not dynamic. The inherited value is set when the offscreen is created, and then remains fixed for the lifetime of the offscreen. The spec text is An OffscreenCanvas object has an internal inherited language and inherited direction set when the OffscreenCanvas s created.
. I think it's important to call this out in a paragraph following this one.
On the demo the best approach would be to set the lang
attribute explicitly to the selected language. If fact, I think that's the only way to have the language change on the offscreen after creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thank you for helping me understand this, @schenney-chromium!
So, I've added an explanation to the "Value" section, and also updated the off-screen demo to suit so that it works as expected (I've also added text to explain the difference between the demos).
Can you have another look and let me know what you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks again. Not sure if an MDN reviewer needs to also review, but I would recommend it as I am inexperienced with MDN style and conventions (at least from an authoring perspective).
Great stuff, thanks for the tech review!
I always do a separate editorial review phase after the tech review, as a standard part of the procedure, so we're all good. |
I do have some more detailed comments on this PR, that I'll get to, but my initial comment is that this seems to be burying the lede. As I understand things, the key message, and the reason this property exists, is like this:
The Is this correct? If so, I think we should say this, which we don't currently. There is some stuff like this, after "Due to technical limitations...", but these are presented as limitations of the But I'm wondering my understanding is correct, because if it is, some other things are wrong. For example:
...this presents the issue as just one of dynamic updates, but if I'm right, the |
The behavior is messy for offscreen. If the offscreen was transferred from a canvas element the
Right, that's the biggest improvement.
Mostly yes, except for the transferred context case. I went through all the complexity of describing this when writing the spec. I agree that giving the general outline then having a section specifically discussing the |
I hear you, @wbamberg. I've just pushed a commit that adds the desired explanation to a new description section, along with the This will probably require a bit more wrangling, as it is somewhat fiddly to make sense of, but I think we're getting close. |
Description
Chrome 136 supports the lang attribute for on- and off-screen canvas 2D drawing contexts: see https://chromestatus.com/feature/5066778773028864.
This PR adds documentation for the new attribute.
Motivation
Additional details
Related issues and pull requests